<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>宇成建筑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../statics/css/font.css">
    <link rel="stylesheet" href="../statics/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="../statics/css/xadmin.css">
    <link rel="stylesheet" href="../statics/css/style.css">
    <style>
        .layui-table-grid-down {
            display: none;
        }

        .layui-table td, .layui-table th {
            min-width: 40px;
        }
    </style>
</head>

<body class='labelAuto'>
<div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="welcome.html">首页</a>
            <a href="javascript:;">财务管理</a>
            <a href="javascript:;">工人工资结算</a>
            <a>
                <cite><span class="employeeName"></span>工资详情</cite>
            </a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right:10px"
       onclick="window.history.go(-1)" title="后退">
        <i class="iconfontBlod" style="line-height:30px">&#xe74f;</i>
    </a>
</div>
<div class="layui-fluid labelAuto">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-tab layui-tab-brief" lay-filter="wage">
                        <ul class="layui-tab-title">
                            <li class="layui-this">概况</li>
                            <li>施工分账</li>
                            <li>杂工分账</li>
                            <li>考勤</li>
                            <li>材料费</li>
                            <li>借款</li>
                            <li>生活费充值</li>
                            <li>生活费退款</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <table class="layui-table" id='wages' lay-filter="test"></table>
                            </div>
                            <div class="layui-tab-item empty">
                                <div class="layui-collapse" lay-accordion>
                                    <div class="layui-colla-item">
                                        <h2 class="layui-colla-title">读取中...</h2>
                                        <div class="layui-colla-content layui-show">读取中...</div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item empty">
                                <div class="layui-collapse" lay-accordion>
                                    <div class="layui-colla-item">
                                        <h2 class="layui-colla-title">读取中...</h2>
                                        <div class="layui-colla-content layui-show">读取中...</div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item empty">
                                <table class="layui-table" id='attendance' lay-filter="attendance"></table>
                            </div>
                            <div class="layui-tab-item empty">
                                <div class="layui-collapse" lay-accordion>
                                    <div class="layui-colla-item">
                                        <h2 class="layui-colla-title">读取中...</h2>
                                        <div class="layui-colla-content layui-show">读取中...</div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item empty">
                                <div class="layui-collapse" lay-accordion>
                                    <div class="layui-colla-item">
                                        <h2 class="layui-colla-title">读取中...</h2>
                                        <div class="layui-colla-content layui-show">读取中...</div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item empty">
                                <div class="layui-collapse" lay-accordion>
                                    <div class="layui-colla-item">
                                        <h2 class="layui-colla-title">读取中...</h2>
                                        <div class="layui-colla-content layui-show">读取中...</div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item empty">
                                <div class="layui-collapse" lay-accordion>
                                    <div class="layui-colla-item">
                                        <h2 class="layui-colla-title">读取中...</h2>
                                        <div class="layui-colla-content layui-show">读取中...</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="../statics/plugins/layui-v2.5.5/layui/layui.js" charset="utf-8"></script>
<script src='../statics/plugins/jQuery-3.2.1/jquery-3.2.1.min.js'></script>
<script type="text/javascript" src="../statics/plugins/X-admin/xadmin.js"></script>
<script type="text/javascript" src="../statics/js/public.js?v=1129"></script>
<script type="text/javascript">
    layui.use(['element', "table"], function () {
        var table = layui.table;
        var element = layui.element;
        var id = getQueryString('id');
        var info = '';
        var employeeName = localStorage.getItem('employeeName');
        $('span.employeeName').empty().html(employeeName);
        $.ajax({
            url: url + '/hrm/employee/info',
            type: "post",
            async: false,
            data: {
                id: id,
                token: getToken()
            },
            dataType: "json",
            success: function (r) {
                if (r.code == 100000) {
                    info = r.data
                } else {
                    tips('详情', r);
                }
            }
        });

        // 异步数据读取
        var lists = table.render({
            elem: '#wages', //绑定DOM元素
            id: 'lists', //table的id
            title: '人员列表',
            height: 'full-180',
            cellMinWidth: 60,
            contentType: "application/json; charset=utf-8",
            url: url + '/finance/wage/personalWage', //数据接口地址
            method: 'POST',
            parseData: function (res) {
                return {
                    "code": res.code, //解析接口状态
                    "data": res.data,
                    "msg": res.msg,
                };
            },
            where: {
                id: id,
                token: getToken()
            },
            page: false, //开启分页
            cols: [
                [ //表头
                    {
                        field: '', title: '月份', width: '10%', totalRowText: '总计', templet: function (d) {
                            return d.LAY_TABLE_INDEX;
                        }
                    },
                    {
                        field: 'income',
                        title: '收入汇总',
                        width: '10%',
                        style: 'color:darkcyan;font-weight: 700;',
                        templet: function (d) {
                            return Number(d.workmanAccounts) + Number(d.handymanAccounts) + Number(d.attendance) * Number(info.dayValue);
                        }
                    },
                    {
                        field: 'workmanAccounts',
                        title: '施工分账',
                        width: '10%',
                        style: 'color:darkcyan;font-weight: 700;',
                        templet: function (d) {
                            return Number(d.workmanAccounts);
                        }
                    },
                    {
                        field: 'handymanAccounts',
                        title: '杂工分账',
                        width: '10%',
                        style: 'color:darkcyan;font-weight: 700;',
                        templet: function (d) {
                            return Number(d.handymanAccounts);
                        }
                    },
                    {
                        field: 'attendance', title: '考勤天数', width: '8%', templet: function (d) {
                            return Number(d.attendance);
                        }
                    },
                    {
                        field: 'attendanceAccounts',
                        title: '考勤工资',
                        width: '10%',
                        style: 'color:darkcyan;font-weight: 700;',
                        templet: function (d) {
                            return Number(d.attendance) * Number(info.dayValue);
                        }
                    },
                    {
                        field: 'materialAccounts',
                        title: '材料费',
                        width: '8%',
                        style: 'color:lightcoral;font-weight: 700;',
                        templet: function (d) {
                            return Number(d.materialAccounts);
                        }
                    },
                    {
                        field: 'loan',
                        title: '借款',
                        width: '8%',
                        style: 'color:lightcoral;font-weight: 700;',
                        templet: function (d) {
                            return Number(d.loan);
                        }
                    },
                    {
                        field: 'livingRecharge',
                        title: '生活费充值',
                        width: '8%',
                        style: 'color:lightcoral;font-weight: 700;',
                        templet: function (d) {
                            return Number(d.livingRecharge);
                        }
                    },
                    {
                        field: 'livingRefund',
                        title: '生活费退款',
                        width: '8%',
                        style: 'color:lightcoral;font-weight: 700;',
                        templet: function (d) {
                            return Number(d.livingRefund);
                        }
                    },
                    {
                        field: 'balance',
                        title: '结余',
                        style: 'color:darkcyan;font-weight: 700;',
                        templet: function (d) {
                            var zj = Number(d.workmanAccounts)
                                + Number(d.handymanAccounts)
                                + Number(d.attendance) * Number(info.dayValue)
                                - Number(d.materialAccounts)
                                - Number(d.livingRecharge)
                                + Number(d.livingRefund)
                                - Number(d.loan);
                            if (zj < 0) {
                                return `<span style="color:lightcoral;font-weight: 700;">${zj}</span>`
                            } else {
                                return `<span style="color:darkcyan;font-weight: 700;">${zj}</span>`;
                            }
                        }
                    },
                ]
            ],
            totalRow: true,
            response: {
                statusName: 'code', //数据状态的字段名称，默认：code
                statusCode: 100000, //成功的状态码，默认：0
                msgName: 'msg', //状态信息的字段名称，默认：msg
                countName: 'count', //数据总数的字段名称，默认：count
                dataName: 'data' //数据列表的字段名称，默认：data
            },
            done: function (res, curr, count) {
                var workmanAccounts = handymanAccounts = attendance = attendanceAccounts = materialAccounts = loan = livingRecharge = livingRefund = 0;
                for (var i in res.data) {
                    workmanAccounts += res.data[i].workmanAccounts;
                    handymanAccounts += res.data[i].handymanAccounts;
                    attendance += Number(res.data[i].attendance);
                    attendanceAccounts += res.data[i].attendance * info.dayValue;
                    materialAccounts += res.data[i].materialAccounts;
                    loan += res.data[i].loan;
                    livingRecharge += res.data[i].livingRecharge;
                    livingRefund += res.data[i].livingRefund;
                }
                var income = workmanAccounts + handymanAccounts + attendanceAccounts;
                var balance = income - materialAccounts - loan - livingRecharge + livingRefund;
                $('.layui-table-total td[data-field=income] div').empty().html(income);
                $('.layui-table-total td[data-field=workmanAccounts] div').empty().html(workmanAccounts);
                $('.layui-table-total td[data-field=handymanAccounts] div').empty().html(handymanAccounts);
                $('.layui-table-total td[data-field=attendance] div').empty().html(attendance);
                $('.layui-table-total td[data-field=attendanceAccounts] div').empty().html(attendanceAccounts);
                $('.layui-table-total td[data-field=materialAccounts] div').empty().html(materialAccounts);
                $('.layui-table-total td[data-field=loan] div').empty().html(loan);
                $('.layui-table-total td[data-field=livingRecharge] div').empty().html(livingRecharge);
                $('.layui-table-total td[data-field=livingRefund] div').empty().html(livingRefund);
                $('.layui-table-total td[data-field=balance] div').empty().html(balance);
                permission();
            }
        });

        element.on('tab(wage)', function (data) {
            var ele = $('.layui-tab-item').eq(data.index);
            if (ele.hasClass('empty')) {
                switch (data.index) {
                    case 1:
                        loadWorkmanAccounts(ele);
                        break;
                    case 2:
                        loadHandymanAccounts(ele);
                        break;
                    case 3:
                        loadAttendance(ele);
                        break;
                    case 4:
                        loadMaterialAccounts(ele);
                        break;
                    case 5:
                        loadLoan(ele);
                        break;
                    case 6:
                        loadLivingRecharge(ele);
                        break;
                    case 7:
                        loadLivingRefund(ele);
                        break;
                }
                element.render();
            }
        });

        function loadWorkmanAccounts(ele) {
            var data = '';
            $.ajax({
                url: url + '/finance/wage/personalWageWorkmanAccounts',
                type: "post",
                async: false,
                data: {
                    id: id,
                    token: getToken()
                },
                dataType: "json",
                success: function (r) {
                    if (r.code === 100000) {
                        data = r.data
                    } else {
                        tips('施工分账', r);
                    }
                }
            });
            var collaItems = '';
            ele.find('div.layui-collapse').empty();
            for (var i in data) {
                //组装折叠面板
                collaItems = `<div class="layui-colla-item">
                                  <h2 class="layui-colla-title"><span>${i}</span><span class="total" style="margin-left: 15px"></span></h2>
                                  <div class="layui-colla-content"><table class="layui-table" id='wa-${i}' lay-filter="wa-${i}"></table></div>
                              </div>`
                //动态追加折叠面板
                ele.find('div.layui-collapse').append(collaItems);
                //实例化table
                var total = 0;
                if (data[i] === '') {
                    ele.find('div.layui-collapse .layui-colla-content:last').empty().html('暂无数据');
                    ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：- 元');
                    continue;
                }
                table.render({
                    elem: `#wa-${i}`, //绑定DOM元素
                    id: `wa-${i}`, //table的id
                    title: '人员列表',
                    height: 'full-180',
                    cellMinWidth: 60,
                    page: false, //开启分页
                    data: data[i],
                    limit: data[i].length,
                    text: {
                        none: '暂无相关数据'
                    },
                    cols: [
                        [ //表头
                            {field: '', title: '编号', type: 'numbers', width: '6%', totalRowText: '总计'},
                            {field: 'projectName', title: '项目', width: '14%',},
                            {field: 'areaName', title: '施工区', width: '14%',},
                            {field: 'sectionName', title: '施工段', width: '14%',},
                            {
                                field: 'account', title: '分账金额', width: '10%', templet: function (d) {
                                    total += Number(d.account);
                                    return Number(d.account);
                                }
                            },
                            {field: 'remark', title: '备注', width: '15%',},
                            {field: 'batch', title: '批次', width: '6%',},
                            {
                                field: 'separateTime', title: '分账时间', width: '10%', templet: function (d) {
                                    return d.separateTime.substr(0, 10);
                                }
                            },
                            {field: 'adminName', title: '记录人', width: '10%',}
                        ]
                    ],
                    done: function () {
                        ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：' + total + ' 元');
                    }
                })
            }
            element.render();
            ele.removeClass('empty')
        }

        function loadHandymanAccounts(ele) {
            var data = '';
            $.ajax({
                url: url + '/finance/wage/personalWageHandymanAccounts',
                type: "post",
                async: false,
                data: {
                    id: id,
                    token: getToken()
                },
                dataType: "json",
                success: function (r) {
                    if (r.code === 100000) {
                        data = r.data
                    } else {
                        tips('杂工分账', r);
                    }
                }
            });

            var collaItems = '';
            ele.find('div.layui-collapse').empty();
            for (var i in data) {
                //组装折叠面板
                collaItems = `<div class="layui-colla-item">
                                  <h2 class="layui-colla-title"><span>${i}</span><span class="total" style="margin-left: 15px"></span></h2>
                                  <div class="layui-colla-content"><table class="layui-table" id='ha-${i}' lay-filter="ha-${i}"></table></div>
                              </div>`
                //动态追加折叠面板
                ele.find('div.layui-collapse').append(collaItems);
                //实例化table
                var total = 0;
                if (data[i] === '') {
                    ele.find('div.layui-collapse .layui-colla-content:last').empty().html('暂无数据');
                    ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：- 元');
                    continue;
                }
                table.render({
                    elem: `#ha-${i}`, //绑定DOM元素
                    id: `ha-${i}`, //table的id
                    title: '人员列表',
                    height: 'full-210',
                    cellMinWidth: 60,
                    page: false, //开启分页
                    data: data[i],
                    limit: data[i].length,
                    text: {
                        none: '暂无相关数据'
                    },
                    cols: [
                        [ //表头
                            {field: '', title: '编号', type: 'numbers', width: '4%', totalRowText: '总计'},
                            {field: 'projectName', title: '项目', width: '14%',},
                            {field: 'areaName', title: '施工区', width: '10%',},
                            {field: 'sectionName', title: '施工段', width: '10%',},
                            {field: 'professionName', title: '工种', width: '5%',},
                            {field: 'assignmentName', title: '施工项', width: '12%',},
                            {field: 'assignmentDetail', title: '施工内容', width: '17%',},
                            {
                                field: 'account', title: '分账金额', width: '8%', templet: function (d) {
                                    total += Number(d.account);
                                    return Number(d.account);
                                }
                            },
                            {
                                field: 'separateTime', title: '分账时间', width: '8%', templet: function (d) {
                                    return d.separateTime.substr(0, 10);
                                }
                            },
                            {field: 'adminName', title: '记录人', width: '8%',}
                        ]
                    ],
                    done: function () {
                        ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：' + total + ' 元');
                    }
                })
            }
            element.render();
            ele.removeClass('empty')
        }

        function loadAttendance(ele) {
            table.render({
                elem: '#attendance', //绑定DOM元素
                id: 'attendance', //table的id
                title: '人员列表',
                height: 'full-150',
                contentType: "application/json; charset=utf-8",
                url: url + '/finance/wage/personalWageAttendance', //数据接口地址
                request: {
                    pageName: 'page', //页码的参数名称，默认：page
                    limitName: 'length' //每页数据量的参数名，默认：limit
                },
                method: 'POST',
                parseData: function (res) {
                    return {
                        "code": res.code, //解析接口状态
                        "data": res.data,
                        "msg": res.msg,
                    };
                },
                where: {
                    id: id,
                    token: getToken()
                },
                page: false, //开启分页
                limit: 10, //默认每页记录条数
                limits: [10, 20, 50], //每页记录条数可选数量
                cols: [[
                    {
                        field: '', title: '编号', width: 80, fixed: 'left', templet: function (d) {
                            if (d.LAY_TABLE_INDEX ==='total'){
                                return '合计';
                            }else{
                                return d.LAY_TABLE_INDEX
                            }
                        }
                    },
                    {
                        field: 1, title: 1, templet: function (d) {
                            return columnCallBack(d, 1)
                        }
                    },
                    {
                        field: 2, title: 2, templet: function (d) {
                            return columnCallBack(d, 2)
                        }
                    },
                    {
                        field: 3, title: 3, templet: function (d) {
                            return columnCallBack(d, 3)
                        }
                    },
                    {
                        field: 4, title: 4, templet: function (d) {
                            return columnCallBack(d, 4)
                        }
                    },
                    {
                        field: 5, title: 5, templet: function (d) {
                            return columnCallBack(d, 5)
                        }
                    },
                    {
                        field: 6, title: 6, templet: function (d) {
                            return columnCallBack(d, 6)
                        }
                    },
                    {
                        field: 7, title: 7, templet: function (d) {
                            return columnCallBack(d, 7)
                        }
                    },
                    {
                        field: 8, title: 8, templet: function (d) {
                            return columnCallBack(d, 8)
                        }
                    },
                    {
                        field: 9, title: 9, templet: function (d) {
                            return columnCallBack(d, 9)
                        }
                    },
                    {
                        field: 10, title: 10, templet: function (d) {
                            return columnCallBack(d, 10)
                        }
                    },
                    {
                        field: 11, title: 11, templet: function (d) {
                            return columnCallBack(d, 11)
                        }
                    },
                    {
                        field: 12, title: 12, templet: function (d) {
                            return columnCallBack(d, 12)
                        }
                    },
                    {
                        field: 13, title: 13, templet: function (d) {
                            return columnCallBack(d, 13)
                        }
                    },
                    {
                        field: 14, title: 14, templet: function (d) {
                            return columnCallBack(d, 14)
                        }
                    },
                    {
                        field: 15, title: 15, templet: function (d) {
                            return columnCallBack(d, 15)
                        }
                    },
                    {
                        field: 16, title: 16, templet: function (d) {
                            return columnCallBack(d, 16)
                        }
                    },
                    {
                        field: 17, title: 17, templet: function (d) {
                            return columnCallBack(d, 17)
                        }
                    },
                    {
                        field: 18, title: 18, templet: function (d) {
                            return columnCallBack(d, 18)
                        }
                    },
                    {
                        field: 19, title: 19, templet: function (d) {
                            return columnCallBack(d, 19)
                        }
                    },
                    {
                        field: 20, title: 20, templet: function (d) {
                            return columnCallBack(d, 20)
                        }
                    },
                    {
                        field: 21, title: 21, templet: function (d) {
                            return columnCallBack(d, 21)
                        }
                    },
                    {
                        field: 22, title: 22, templet: function (d) {
                            return columnCallBack(d, 22)
                        }
                    },
                    {
                        field: 23, title: 23, templet: function (d) {
                            return columnCallBack(d, 23)
                        }
                    },
                    {
                        field: 24, title: 24, templet: function (d) {
                            return columnCallBack(d, 24)
                        }
                    },
                    {
                        field: 25, title: 25, templet: function (d) {
                            return columnCallBack(d, 25)
                        }
                    },
                    {
                        field: 26, title: 26, templet: function (d) {
                            return columnCallBack(d, 26)
                        }
                    },
                    {
                        field: 27, title: 27, templet: function (d) {
                            return columnCallBack(d, 27)
                        }
                    },
                    {
                        field: 28, title: 28, templet: function (d) {
                            return columnCallBack(d, 28)
                        }
                    },
                    {
                        field: 29, title: 29, templet: function (d) {
                            return columnCallBack(d, 29)
                        }
                    },
                    {
                        field: 30, title: 30, templet: function (d) {
                            return columnCallBack(d, 30)
                        }
                    },
                    {
                        field: 31, title: 31, templet: function (d) {
                            return columnCallBack(d, 31)
                        }
                    },
                    {
                        field: 'sum', title: '汇总', width: 70, templet: function (d) {
                            if(d.LAY_TABLE_INDEX === 'total'){
                                return d.total;
                            }else{
                                var sum = 0;
                                for (var i in d) {
                                    if (typeof d[i] == 'object') {
                                        sum += Number(d[i].long);
                                    }
                                }
                                return `<span title="">${sum}</span>`;
                            }
                        }
                    },
                ]],
                totalRow:true,
                response: {
                    statusName: 'code', //数据状态的字段名称，默认：code
                    statusCode: 100000, //成功的状态码，默认：0
                    msgName: 'msg', //状态信息的字段名称，默认：msg
                    countName: 'count', //数据总数的字段名称，默认：count
                    dataName: 'data' //数据列表的字段名称，默认：data
                },
                done: function (res, curr, count) {
                    this.cols = []; //（关键代码）将cols初始化，否则表格重载时无法正确重新渲染表头
                }
            });
            ele.removeClass('empty')
        }

        function columnCallBack(d, i) {
            if (typeof d[i] != 'undefined') {
                return `<span title="${d[i].projectName}">${d[i].long}</span>`
            } else {
                return `---`;
            }
        }

        function loadMaterialAccounts(ele) {
            var data = '';
            $.ajax({
                url: url + '/finance/wage/personalWageMaterialAccounts',
                type: "post",
                async: false,
                data: {
                    id: id,
                    token: getToken()
                },
                dataType: "json",
                success: function (r) {
                    if (r.code === 100000) {
                        data = r.data
                    } else {
                        tips('材料费', r);
                    }
                }
            });

            var collaItems = '';
            ele.find('div.layui-collapse').empty();
            for (var i in data) {
                //组装折叠面板
                collaItems = `<div class="layui-colla-item">
                                  <h2 class="layui-colla-title"><span>${i}</span><span class="total" style="margin-left: 15px"></span></h2>
                                  <div class="layui-colla-content"><table class="layui-table" id='ha-${i}' lay-filter="ha-${i}"></table></div>
                              </div>`
                //动态追加折叠面板
                ele.find('div.layui-collapse').append(collaItems);
                //实例化table
                var total = 0;
                if (data[i] === '') {
                    ele.find('div.layui-collapse .layui-colla-content:last').empty().html('暂无数据');
                    ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：- 元');
                    continue;
                }
                table.render({
                    elem: `#ha-${i}`, //绑定DOM元素
                    id: `ha-${i}`, //table的id
                    title: '人员列表',
                    height: 'full-210',
                    cellMinWidth: 60,
                    page: false, //开启分页
                    data: data[i],
                    limit: data[i].length,
                    text: {
                        none: '暂无相关数据'
                    },
                    cols: [
                        [ //表头
                            {field: '', title: '编号', type: 'numbers', width: '6%'},
                            {field: 'materialName', title: '材料名称', width: '180'},
                            {field: 'spec', title: '规格型号', width: '120'},
                            {
                                field: 'time', title: '入/出库时间', width: '100', templet: function (d) {
                                    return (d.time).substr(0, 10);
                                }
                            },
                            {field: 'amount', title: '数量', width: '70'},
                            {field: 'unitName', title: '单位'},
                            {field: 'price', title: '收储价格（元）', width: '100'},
                            {
                                field: 'totalPrice', title: '总价（元）', width: '90', templet: function (d) {
                                    total += Number(d.totalPrice);
                                    return d.totalPrice;
                                }
                            },
                            {
                                field: 'type', title: '类型', width: '85', templet: function (d) {
                                    return '个人领料';
                                }
                            },
                            {field: 'sourceEmployeeName', title: '来源/去向', width: '90'},
                            {
                                field: 'createTime', title: '记录时间', width: '100', templet: function (d) {
                                    return (d.createTime).substr(0, 10);
                                }
                            },
                        ]
                    ],
                    done: function () {
                        ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：' + total + ' 元');
                    }
                })
            }
            element.render();
            ele.removeClass('empty')
        }

        function loadLoan(ele) {
            var data = '';
            $.ajax({
                url: url + '/finance/wage/personalWageLoan',
                type: "post",
                async: false,
                data: {
                    id: id,
                    token: getToken()
                },
                dataType: "json",
                success: function (r) {
                    if (r.code === 100000) {
                        data = r.data
                    } else {
                        tips('借支', r);
                    }
                }
            });

            var collaItems = '';
            ele.find('div.layui-collapse').empty();
            for (var i in data) {
                //组装折叠面板
                collaItems = `<div class="layui-colla-item">
                                  <h2 class="layui-colla-title"><span>${i}</span><span class="total" style="margin-left: 15px"></span></h2>
                                  <div class="layui-colla-content"><table class="layui-table" id='ha-${i}' lay-filter="ha-${i}"></table></div>
                              </div>`
                //动态追加折叠面板
                ele.find('div.layui-collapse').append(collaItems);
                //实例化table
                var total = 0;
                if (data[i] === '') {
                    ele.find('div.layui-collapse .layui-colla-content:last').empty().html('暂无数据');
                    ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：- 元');
                    continue;
                }
                table.render({
                    elem: `#ha-${i}`, //绑定DOM元素
                    id: `ha-${i}`, //table的id
                    title: '人员列表',
                    height: 'full-210',
                    cellMinWidth: 60,
                    page: false, //开启分页
                    data: data[i],
                    limit: data[i].length,
                    text: {
                        none: '暂无相关数据'
                    },
                    cols: [
                        [ //表头
                            {field: '', title: '编号', type: 'numbers', width: '8%'},
                            {field: 'projectName', title: '项目名称'},
                            {field: 'employeeName', title: '工人'},
                            {
                                field: 'account', title: '借支金额', templet: function (d) {
                                    total += Number(d.account);
                                    return Number(d.account);
                                }
                            },
                            {field: 'remark', title: '备注'},
                            {
                                field: 'loanTime', title: '借支时间', width: '8%', templet: function (d) {
                                    return (d.loanTime).substr(0, 10);
                                }
                            },
                        ]
                    ],
                    done: function () {
                        ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：' + total + ' 元');
                    }
                })
            }
            element.render();
            ele.removeClass('empty')
        }

        function loadLivingRecharge(ele) {
            var data = '';
            $.ajax({
                url: url + '/finance/wage/personalWageLivingRecharge',
                type: "post",
                async: false,
                data: {
                    id: id,
                    token: getToken()
                },
                dataType: "json",
                success: function (r) {
                    if (r.code === 100000) {
                        data = r.data
                    } else {
                        tips('生活费充值', r);
                    }
                }
            });

            var collaItems = '';
            ele.find('div.layui-collapse').empty();
            for (var i in data) {
                //组装折叠面板
                collaItems = `<div class="layui-colla-item">
                                  <h2 class="layui-colla-title"><span>${i}</span><span class="total" style="margin-left: 15px"></span></h2>
                                  <div class="layui-colla-content"><table class="layui-table" id='ha-${i}' lay-filter="ha-${i}"></table></div>
                              </div>`
                //动态追加折叠面板
                ele.find('div.layui-collapse').append(collaItems);
                //实例化table
                var total = 0;
                if (data[i] === '') {
                    ele.find('div.layui-collapse .layui-colla-content:last').empty().html('暂无数据');
                    ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：- 元');
                    continue;
                }
                table.render({
                    elem: `#ha-${i}`, //绑定DOM元素
                    id: `ha-${i}`, //table的id
                    title: '人员列表',
                    height: 'full-210',
                    cellMinWidth: 60,
                    page: false, //开启分页
                    data: data[i],
                    limit: data[i].length,
                    text: {
                        none: '暂无相关数据'
                    },
                    cols: [
                        [ //表头
                            {field: '', title: '编号', type: 'numbers', width: '8%'},
                            {field: 'projectName', title: '项目名称'},
                            {field: 'employeeName', title: '工人'},
                            {
                                field: 'account', title: '生活费金额', templet: function (d) {
                                    total += Number(d.account);
                                    return Number(d.account);
                                }
                            },
                            {field: 'remark', title: '备注'},
                            {field: 'livingTime', title: '充值时间'},
                        ]
                    ],
                    done: function () {
                        ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：' + total + ' 元');
                    }
                })
            }
            element.render();
            ele.removeClass('empty')
        }

        function loadLivingRefund(ele) {
            var data = '';
            $.ajax({
                url: url + '/finance/wage/personalWageLivingRefund',
                type: "post",
                async: false,
                data: {
                    id: id,
                    token: getToken()
                },
                dataType: "json",
                success: function (r) {
                    if (r.code === 100000) {
                        data = r.data
                    } else {
                        tips('生活费退款', r);
                    }
                }
            });

            var collaItems = '';
            ele.find('div.layui-collapse').empty();
            for (var i in data) {
                //组装折叠面板
                collaItems = `<div class="layui-colla-item">
                                  <h2 class="layui-colla-title"><span>${i}</span><span class="total" style="margin-left: 15px"></span></h2>
                                  <div class="layui-colla-content"><table class="layui-table" id='ha-${i}' lay-filter="ha-${i}"></table></div>
                              </div>`
                //动态追加折叠面板
                ele.find('div.layui-collapse').append(collaItems);
                //实例化table
                var total = 0;
                if (data[i] === '') {
                    ele.find('div.layui-collapse .layui-colla-content:last').empty().html('暂无数据');
                    ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：- 元');
                    continue;
                }
                table.render({
                    elem: `#ha-${i}`, //绑定DOM元素
                    id: `ha-${i}`, //table的id
                    title: '人员列表',
                    height: 'full-210',
                    cellMinWidth: 60,
                    page: false, //开启分页
                    data: data[i],
                    limit: data[i].length,
                    text: {
                        none: '暂无相关数据'
                    },
                    cols: [
                        [ //表头
                            {field: '', title: '编号', type: 'numbers', width: '8%'},
                            {field: 'projectName', title: '项目名称'},
                            {field: 'employeeName', title: '工人'},
                            {
                                field: 'account', title: '生活费金额', templet: function (d) {
                                    total += Number(d.account);
                                    return Number(d.account);
                                }
                            },
                            {field: 'remark', title: '备注'},
                            {field: 'livingTime', title: '退款时间'},
                        ]
                    ],
                    done: function () {
                        ele.find('div.layui-collapse .layui-colla-title:last span.total').empty().html('共计：' + total + ' 元');
                    }
                })
            }
            element.render();
            ele.removeClass('empty')
        }
    });
</script>

</html>